var app = getApp(),
    siteinfo = require("../../../siteinfo.js");

Page({
    data: {
        indicatorDots: !1,
        autoplay: !1,
        interval: 5e3,
        duration: 1e3,
        index: 0,
        getmsg: "获取验证码",
        ac_index: 0,
        succ: !0
    },
    onLoad: function(a) {
        app.setNavigationBarColor(this);
        var s = this,
            e = wx.getStorageSync("users").id;
    },
    code: function(a) {
        this.setData({
            phone: a.detail.value
        });
    },
    sendmessg: function(a) {
        var e = this;
        var t = e.data.phone;
        if ("" == t || null == t) {
            wx.showModal({
                title: "",
                content: "请输入手机号"
            });
        } else {
            for (var o = "", s = 0; s < 6; s++) o += Math.floor(10 * Math.random());
            app.util.request({
                url: "entry/wxapp/sms2",
                cachetime: "0",
                data: {
                    code: o,
                    tel: t
                },
                success: function(a) {
                }
            }), 
            e.setData({
                num: o
            });
            var n = 59,
                i = setInterval(function() {
                    e.setData({
                        getmsg: n + "s后重新发送",
                        send: !0
                    }), --n <= 0 && (clearInterval(i), e.setData({
                        getmsg: "获取验证码",
                        send: !1
                    }));
                }, 1e3);
        }
    },
    //立即成为代理
    formSubmit: function(a) {
        var t = this.data,
            e = a.detail.value,
            username = e.username,
            mangername = e.mangername,
            city_name = e.city_name,
            mobile = e.mobile,
            code = e.code,
            user_id = wx.getStorageSync("users").id;
        var q = "";
        "" == username ? q = "请输入个人姓名" : "" == mangername ? q = "请输入公司名称" : "" == city_name ? q = "请输入代理城市" : "" == mobile ? q = "请输入您的手机号" : "" == code ? q = "请输入验证码" : "";
        if (q != '') {
            wx.showToast({
                icon:"none",
                title: q,
            })
            return false;
        }
        app.util.request({
            url: "entry/wxapp/AgentApply",
            cachetime: "0",
            data: {
                user_id: user_id,
                username: username,
                mangername: mangername,
                city_id: 1,
                city_name: city_name,
                mobile: mobile
            },
            success: function(a) {
                wx.showModal({
                    title: '提示!',
                    content: '城市代理申请成功！',
                    success: function(res) {
                        if (res.confirm) {
                            wx.switchTab({
                                url: '../my/index'
                            })
                        }
                    }
                })
            }
        });

    }
});